package svc

import (
	model "paper-pro/app/assistant/model/assistant"
	"paper-pro/app/assistant/rpc/internal/config"
	"paper-pro/pkg/rpc/chat/client/chatdialogservice"

	"github.com/zeromicro/go-queue/dq"
	"github.com/zeromicro/go-zero/core/stores/redis"
	"github.com/zeromicro/go-zero/zrpc"
)

const (
	AssistantDbName         = "assistant"
	AssistantCollectionName = "assistant_infos"
)

type ServiceContext struct {
	Config config.Config

	AssistantModel model.AssistantModel
	ChatDialogRpc  chatdialogservice.ChatDialogService
	RedisClient    *redis.Redis
	DqPusherClient dq.Producer
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config: c,

		AssistantModel: model.NewAssistantModel(
			c.MongoDB.Source, AssistantDbName, AssistantCollectionName, c.Cache),
		ChatDialogRpc:  chatdialogservice.NewChatDialogService(zrpc.MustNewClient(c.ChatDialogRpcConf)),
		RedisClient:    redis.MustNewRedis(c.RedisConf),
		DqPusherClient: dq.NewProducer(c.DqConf),
	}
}
